//
//  NSArray+TXYVideoInfoExtract.m
//  FunnyVideo
//
//  Created by 李鑫 on 15/8/28.
//  Copyright © 2015年 NewEggTech. All rights reserved.
//
#import "AVObject+AVObject_Category.h"
#import "NSArray+TXYVideoInfoExtract.h"
#import "TXYResponseData.h"
#import <AVOSCloud/AVOSCloud.h>


@implementation NSArray (TXYVideoInfoExtract)
#pragma mark -- Video URL Extract
- (NSArray<NSString*> *)extractVideoURLFromTXYResponseInfos{
    NSMutableArray *v_urls = [[NSMutableArray alloc] initWithCapacity:self.count];
    
    for(TXYResponseVideoInfo *info in self)
    {   if([info access_url])
        [v_urls addObject:[info access_url]];
    else
    /**
     *  后期修改 请求不到视频的时候的地址
     */
        [v_urls addObject:@"http://www.baidu.com/1.mp4"];
    }
    
    return [NSArray arrayWithArray:v_urls];
}

- (NSArray *)extractVideoNameFromTXYResponseInfos{
    NSMutableArray *v_names = [[NSMutableArray alloc] initWithCapacity:self.count];
    
    for(TXYResponseVideoInfo *info in self)
    {   if([info name])
        [v_names addObject:[info name]];
    else
        [v_names addObject:@"无"];
    }
    
    return [NSArray arrayWithArray:v_names];
}

- (NSArray *)extractVideoDescriptionFromTXYResponseInfos{
    NSMutableArray *v_Descs = [[NSMutableArray alloc] initWithCapacity:self.count];
    
    for(TXYResponseVideoInfo *info in self)
    {   if([info video_desc])
        [v_Descs addObject:[info video_desc]];
    else
        [v_Descs addObject:@"无"];
    }
    
    return [NSArray arrayWithArray:v_Descs];
}

- (NSArray *)extractVideoUpdateTimeFromTXYResponseInfos{
    NSMutableArray *v_upTimes = [[NSMutableArray alloc] initWithCapacity:self.count];
    
    for(TXYResponseVideoInfo *info in self)
    {   if([info ctime])
    {
        NSString *ctime_Str = [info ctime];
        [v_upTimes addObject:ctime_Str];
    }
    else
        [v_upTimes addObject:[[NSDate date] descriptionWithLocale:[NSLocale systemLocale]]];
    }
    
    return [NSArray arrayWithArray:v_upTimes];
}

- (NSArray *)extractVideoSHAFromTXYResponseInfos{
    NSMutableArray *v_SHAS = [[NSMutableArray alloc] initWithCapacity:self.count];
    
    for(TXYResponseVideoInfo *info in self)
    {   if([info ctime])
    {
        NSString *sha_str = [info sha];
        [v_SHAS addObject:sha_str];
    }
    else
        [v_SHAS addObject:[[NSDate date] descriptionWithLocale:[NSLocale systemLocale]]];
    }
    
    return [NSArray arrayWithArray:v_SHAS];
}
/**
 *
 AVOSVideoInfoTypeContent,
 AVOSVideoInfoTypeVideoName,
 AVOSVideoInfoTypeVideoURL,
 AVOSVideoInfoTypePubUser,
 AVOSVideoInfoTypeCategory,
 AVOSVideoInfoTypeVideoId,
 AVOSVideoInfoTypeComments,
 AVOSVideoInfoTypeLikes,
 AVOSVideoInfoTypeIndex,
 AVOSVideoInfoTypeCreatedAt,
 */

@end
